//部分控制器
var app = angular.module('myApp.controllers');

//example首页
app.controller('insuranceIndex', ["$scope", "utilService", "$rootScope", function ($scope, utilService, $rootScope) {

    /*模拟数据*/
    $scope.insuranceList = [{id:0},{id:1},{id:2},{id:3},{id:4}]
    /*点击到详情*/
    $scope.showDetail = function (item) {
        utilService.$state.go('insurance.detail', {id:item.id});
    }

    $scope.$on('$ionicView.beforeEnter', function () {
        //页面刚加载
        utilService.$ionicLoading.show(HX_CONFIG.loadingBase);
    }, false);
    $scope.$on('$ionicView.afterEnter', function () {
        utilService.$rootScope.rootData.title = '选择保险公司';
        //页面加载完成
        utilService.$ionicLoading.hide();
    }, false);
    $rootScope.$on('$ionicView.beforeLeave', function (e, ion) {
        //页面离开之前
        //alertPopup && alertPopup.close();

    }, false);

}]);
app.controller('insuranceDetail', ["$scope", "utilService", "$rootScope", function ($scope, utilService, $rootScope) {

  $scope.$on('$ionicView.beforeEnter', function () {
    //页面刚加载
    utilService.$ionicLoading.show(HX_CONFIG.loadingBase);
  }, false);
  $scope.$on('$ionicView.afterEnter', function () {
    utilService.$rootScope.rootData.title = '我的车险';
    //页面加载完成
    utilService.$ionicLoading.hide();
  }, false);
  $rootScope.$on('$ionicView.beforeLeave', function (e, ion) {
    //页面离开之前
    //alertPopup && alertPopup.close();

  }, false);

}]);
app.controller('insuranceCall', ["$scope", "utilService", "$rootScope", function ($scope, utilService, $rootScope) {

  $scope.$on('$ionicView.beforeEnter', function () {
    //页面刚加载
    utilService.$ionicLoading.show(HX_CONFIG.loadingBase);
  }, false);
  $scope.$on('$ionicView.afterEnter', function () {
    utilService.$rootScope.rootData.title = '一键联系';
    //页面加载完成
    utilService.$ionicLoading.hide();
  }, false);
  $rootScope.$on('$ionicView.beforeLeave', function (e, ion) {
    //页面离开之前
    //alertPopup && alertPopup.close();

  }, false);

}]);